public class Palindrome {
  public boolean isPalindrome(Node n) {
    String str = "";
    
    if(n == null) return false;
    
    while(n != null) {
      str = str + Integer.toString(n.data);
      n = n.next;
    }
    
    str = str.replaceAll(" ","");
    return (str.reverse().equals(str));
  }
}